package com.ruimei.service.impl;

import com.ruimei.entitys.Parent;
import com.ruimei.entitys.Student;
import com.ruimei.entitys.Teacher;
import com.ruimei.mapper.FileMapper;
import com.ruimei.mapper.StudentMapper;
import com.ruimei.service.FileService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class FileServiceImpl implements FileService {

    @Resource
    FileMapper mapper;

    @Override
    public Map<String, Object> getStudentById(String studentId) {
        Map<String, Object> map = new HashMap();
        Map<String, Object> data = new HashMap();
        Student student = mapper.getStudentById(studentId);
        List<Parent> parents= mapper.getParentByStudentId(studentId);
        data.put("student",student);
        data.put("parents",parents);
        map.put("data",data);
        map.put("message", "success");
        map.put("status", Boolean.valueOf(true));
        return map;
    }

    @Override
    public Map<String, Object> searchTeacher(String teacherName) {
        Map<String, Object> map = new HashMap();
        Map<String, Object> data = new HashMap();
        List<Teacher> teacher = mapper.searchTeacher(teacherName);
        data.put("teacher",teacher);
        map.put("data",data);
        map.put("message", "success");
        map.put("status", Boolean.valueOf(true));
        return map;
    }

    @Override
    public Map<String, Object> searchStudent(String studentName) {
        Map<String, Object> map = new HashMap();
        Map<String, Object> data = new HashMap();
        List<Student> student = mapper.searchStudent(studentName);
        data.put("student",student);
        map.put("data",data);
        map.put("message", "success");
        map.put("status", Boolean.valueOf(true));
        return map;
    }
}
